/** *******************************************************************
 * FlexDatabaseManager
 * Copyright (c) 2008 Jonnie Spratley. All Rights Reserved.
 * @author  Jonnie Spratley
 * @contact jonniespratley@gmail.com
 * @internal
 ******************************************************************* */
package com.jonniespratley.flexdatabasemanager.commands.databases
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.commands.SequenceCommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.jonniespratley.flexdatabasemanager.events.databases.SelectedDatabaseEvent;
	import com.jonniespratley.flexdatabasemanager.events.tables.ShowTableStatusEvent;
	import com.jonniespratley.flexdatabasemanager.model.ModelLocator;
	import com.jonniespratley.flexdatabasemanager.vo.*;

	public class SelectedDatabaseCommand extends SequenceCommand implements ICommand
	{
		private var model:ModelLocator = ModelLocator.getInstance();

		override public function execute( event:CairngormEvent ) : void
		{
			var evt:SelectedDatabaseEvent = event as SelectedDatabaseEvent;
			
			//set the model with the selected database
			model.selectedDatabase = evt.aDatabase;
			
			//prepare the next event to dispatch
			nextEvent = evt.nextEventSequence; 
			//create instance
			ShowTableStatusEvent( nextEvent );
			//execute
			executeNextCommand();														 	
		}
	}
}